home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / wuftpd_umask.txt < prev    next >
Text File  |  1998-07-17  |  3KB  |  104 lines

  1.  
  2. The default umask for wu-ftpd 2.4.2-beta-13 is 002.
  3. Since most users on most sites are in the same group, all files created by
  4. users PUTting files would be group writeable by anyone.  Not a good thing.
  5.  
  6. The offending code is in "ftpd.c" line 259:
  7. #if !defined(CMASK) || CMASK == 0
  8. #undef CMASK
  9. #define CMASK 002
  10. #endif
  11.  
  12. Changing CMASK 002 to CMASK 022 will fix this.
  13.  
  14.  
  15. ===========================================================================
  16.  
  17.  
  18. If you aren't easily able to recompile your wu-ftpd, but you are able to
  19. edit its entry in inetd.conf, invoking it with the switch "-u022" will
  20. also let you set the default umask to 022 (you can even use "-u077", if
  21. you're feeling paranoid or fascist).
  22.  
  23.  
  24. ===========================================================================
  25.  
  26.  
  27.  
  28. This is from the Solaris 2.x FAQ:
  29. http://www.wins.uva.nl/pub/solaris/solaris2/
  30.  
  31. 3.48) How can I prevent daemons from creating mode 666 files?
  32.  
  33. By default, all daemons inherit the umask 0 from init. This is most
  34. problematic for a service like ftp, which in a standard configuration
  35. leaves all uploaded files with mode 666.
  36.  
  37. To get daemons to use another umask execute the following commands in
  38. /bin/sh and reboot:
  39.  
  40. umask 022  # make sure umask.sh gets created with the proper mode
  41. echo "umask 022" > /etc/init.d/umask.sh
  42. for d in /etc/rc?.d
  43. do
  44.         ln /etc/init.d/umask.sh $d/S00umask.sh
  45. done
  46.  
  47.  
  48. Note: the trailing ".sh" of the scriptname is important, if you don't
  49. specify it, the script will will be executed in a sub-shell, not in the
  50. main shell that executes all other scripts.
  51.  
  52.  
  53.  
  54. ===========================================================================
  55.  
  56.  
  57.  
  58. There is a potentially serious bug in ftpd.c in wu-ftpd beta 13.  I have
  59. no idea if it exists in previous betas.  I don't think this was a problem
  60. in beta 11, but I've not kept any older source.  If you are not running
  61. beta 13, check this against your source.
  62.  
  63. During anonymous login, the /./ is not clipped off the struct passwd
  64. pw->pw_dir field that is saved as the chroot directory in ftpd.c.
  65.  
  66. Because the /./ is still on the end of the pw->pw_dir field, upl_check()
  67. 'upload' directive processing will fail in extensions.c because the file
  68. name paths will not compare.  It is highly unlikely that the upload
  69. directive root path would also have the /./ on the end.
  70.  
  71. If upload directive processing fails for the anonymous user, sites that
  72. depend on upload directives to properly set incoming file permissions
  73. could find their site security compromised.
  74.  
  75. For example, it is fairly common to set incoming files to not be readable
  76. to the anonymous user; this prevents files from being traded through an
  77. anonymous site without the permission of the owner.  With this bug, all
  78. uploaded files are owned by the anonymous user, with default permissions
  79. set by CMASK.
  80.  
  81. Here is a patch for wu-ftpd beta 13:
  82.  
  83. --- ftpd.c.orig Thu Jun 19 22:59:21 1997
  84. +++ ftpd.c      Thu Jun 19 23:01:26 1997
  85. @@ -1560,12 +1560,7 @@
  86.              pw->pw_dir = sgetsave(virtual_root);
  87.          }
  88.  #endif
  89. -        if (anonymous) {
  90. -            if (chroot(pw->pw_dir) < 0 || chdir("/") < 0) {
  91. -                reply(550, "Can't set guest privileges.");
  92. -                goto bad;
  93. -            }
  94. -        } else if (guest) {
  95. +        if (anonymous || guest) {
  96.              char *sp;
  97.  
  98.              /* determine root and home directory */
  99.  
  100.  
  101.  
  102.  
  103. ===========================================================================
  104.